import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Scanner;
import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.*;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.util.*;
//Current Status - Th
public class mainProj
{
	private static Scanner scanner;
	private ArrayList<Manufacturer> m = new ArrayList<Manufacturer>();
	private JTextField displayField = new JTextField(30);
	private static String option = "";
	//	private

	public static void main(String[] args) throws Exception
	{
		int c = 0;
		ConnectDb connectDb = new ConnectDb();
		Connection connection = connectDb.getDBConnection();
		//HAVE TO MAKE DB WITH MANUFACTURERS
		String [] menu = {"Enter M for query by Manufacturer.", 
				"Enter V for query by vendor and part number",
				"Enter D to delete",
				"Enter U to Update",
				"Enter I to insert",
		"Enter Q to quit.", "Enter S for shopping cart"};

		option = JOptionPane.showInputDialog(menu); // About to work on this.- take the input from the user to know what he wants.

		if(option == null)
		{
			connectDb.disconnectFromDB();
			System.exit(0);
		}
		else
			option= option.toUpperCase();

		//do 
		//{
		if(option.equals("I")){
			String [] insertm = {"Enter C to insert a car.","Enter P to insert part."};
			String option1 = JOptionPane.showInputDialog(insertm);
			option1 = option1.toUpperCase();
			if(option1.equals("C")){
				new Insert(connection,connectDb);
				c++;
			}
			else if(option1.endsWith("P")){
				new InsertPart(connection,connectDb);
			}
		}
		else if(option.equals("M")){
			new QueryGui(connection,connectDb);
			c++;
		}
		else if(option.equals("V")){
			new QueryVendorPartGUI(connection,connectDb);
		}
		else if(option.equals("D")){
			new Delete(connection, connectDb);
		}
		else if(option.equals("U"))
		{
			String [] insertm = {"Enter O to update anything besides a part","Enter P to Update a part."};
			String option1 = JOptionPane.showInputDialog(insertm);
			option1 = option1.toUpperCase();
			if(option1.equals("C")){
				new Update(connection,connectDb,option1);
				//c++;
		}
			else
				new Update(connection,connectDb,option1);
		}
		else if (option.equals("S"))
		{
		    new ShoppingCart(connection, connectDb);
		}
		else
		{
			connectDb.disconnectFromDB();
			System.exit(0);
		}
	}



}


